package com.masterrabbit.service;

import com.masterrabbit.domain.UserCoupons;
import com.masterrabbit.mapper.CouponsMapper;
import com.masterrabbit.mapper.UserCouponsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserCouponsService {
    @Autowired
    private UserCouponsMapper userCouponsMapper;
    @Autowired
    private CouponsMapper couponsMapper;
   public List<UserCoupons> selectByUserId(Integer id){
        List<UserCoupons> userCoupons=userCouponsMapper.selectByUserId(id);
        for (UserCoupons userCoupon:userCoupons){
            if (userCoupon!=null){
                userCoupon.setCoupons(couponsMapper.selectByPrimaryKey(userCoupon.getCouponId()));
            }
        }
        return userCoupons;
    };
}
